//
//  LBEmptyShoppingView.m
//  LvoeBeen_Imitation
//
//  Created by apple on 17/2/19.
//  Copyright © 2017年 itcast. All rights reserved.
//

#import "LBEmptyShoppingView.h"
#import <Masonry.h>

@implementation LBEmptyShoppingView

-(instancetype)init{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    //购物车
    UIImageView *carView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_shop_empty"]];
    [self addSubview:carView];
    //布局
    [carView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self).mas_offset(200);
        make.size.mas_equalTo(150);
    }];
    
    //文字
    UITextField *textF = [[UITextField alloc]init];
    textF.text = @"购物车空空的,赶紧去购物吧";
    textF.textColor = [UIColor grayColor];
    [self addSubview:textF];
    //布局
    [textF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(carView.mas_bottom).mas_offset(30);
        make.centerX.mas_equalTo(self);
    }];
    
    //去逛逛
    UIButton *goShoppingBtn = [[UIButton alloc] init];
    [goShoppingBtn setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
    
    [goShoppingBtn setTitle:@"去逛逛" forState:UIControlStateNormal];
    [goShoppingBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    
    [self addSubview:goShoppingBtn];
    
    //布局
    [goShoppingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(textF.mas_bottom).mas_offset(30);
        make.centerX.mas_equalTo(self);
        make.width.mas_equalTo(150);
        
    }];
    
    //添加点击事件
    [goShoppingBtn addTarget:self action:@selector(clickGoShopping:) forControlEvents:UIControlEventTouchUpInside];
    
}
#pragma mark
#pragma mark - 前往购买商品
- (void)clickGoShopping:(UIButton*)btn{
    if ([self.delegate respondsToSelector:@selector(goShopping)]) {
        [self.delegate goShopping];
    }
}

@end
